<template>
  <div class="laundry">
    <div>
      <el-form ref="dataForm" class="oldIndent_nav">
        <div style="margin-bottom:20px;margin-top:10px;">
          <span style="margin-left:60px">姓名：</span>
          <el-input placeholder="请输入姓名" style="width:200px" />
          <span style="margin-left:60px">电话号码：</span>
          <el-input placeholder="请输入电话" style="width:200px" />
          <span style="margin-left:30px">起始时间:</span>
          <el-date-picker
            type="date"
            placeholder="选择起始时间"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyyMMdd"
          />
          <span style="margin-left:50px">结束时间:</span>
          <el-date-picker
            type="date"
            placeholder="选择结束时间"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyyMMdd"
          />
          <el-button type="primary" round style="float:right;margin-right:200px">查询</el-button>
        </div>
      </el-form>
    </div>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" align="center" label="订单号" />
      <el-table-column prop="time" align="center" label="下单时间" />
      <el-table-column prop="user" align="center" label="下单用户" />
      <el-table-column prop="phone" align="center" label="联系方式" />
      <el-table-column prop="area" align="center" width="250" label="服务地址" />
      <el-table-column prop="time2" align="center" label="上门时间" />
      <el-table-column prop="good" align="center" label="清洗器具" />
      <el-table-column prop="money" align="center" label="金额" />
      <el-table-column prop="state" align="center" label="订单状态" />
      <el-table-column align="center" label="接单员">
        <template slot-scope="scope">
          <span v-show="scope.row.state==='待接单'? false: true">{{ scope.row.user2 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            v-show="scope.row.state==='待接单'? true: false"
            size="small"
            type="success"
            @click="agree(scope.row)"
          >接受订单</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 修改一条 -->
    <el-dialog :visible.sync="dialogFormVisible">
      <el-form
        ref="dataForm"
        :rules="rules"
        :model="temp"
        label-position="left"
        label-width="70px"
        style="width: 400px; margin-left:50px;"
      >
        <el-form-item label="订单号:">
          <span>{{ card_id }}</span>
        </el-form-item>
        <el-form-item label="接单人:">
          <el-input v-model="input" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确定接受</el-button>
      </div>
    </el-dialog>
    <!-- 分页 -->
    <el-col :span="24" class="toolbar" style="text-align: center;">
      <el-pagination
        background
        :current-page="currentPage"
        :page-count="pageNum"
        :page-size="pagesize"
        style="margin-top:30px;margin-bottom:30px"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-col>
  </div>
</template>
<script>
export default {
  data() {
    return {
      currentPage: 1, // 初始页
      pagesize: 10, // 当前页面内的列表行数
      pageCount: 1,
      pageNum: 1, // 页数
      total: 4,
      rules: {},
      card_id: '',
      input: '',
      temp: {},
      dialogFormVisible: false,
      tableData: [
        {
          id: '156545652',
          time: '2019-12-02 18:02',
          time2: '2019-12-03 08:00',
          good: '马桶',
          user: '王先生',
          phone: '1328845219',
          area: '浙江省杭州市下城区下沙大都会风情苑9幢4单元201室',
          money: '60元',
          state: '待接单',
          user2: '保洁员刘娥'
        },
        {
          id: '7895613521',
          time: '2019-12-02 19:34',
          time2: '2019-12-03 10:00',
          good: '清洗净水器',
          user: '赵先生',
          phone: '13156565656',
          area: '浙江省杭州市下城区下沙大都会风情苑7幢9单元702室',
          money: '70元',
          state: '待接单',
          user2: '保洁员刘娥'
        }, {
          id: '1564322231',
          time: '2019-12-04 19:34',
          time2: '2019-12-05 08:00',
          good: '清洗电动车',
          user: '吴先生',
          phone: '13199451349',
          area: '浙江省杭州市下城区下沙大都会风情苑11幢1单元101室',
          money: '50元',
          state: '已完成',
          user2: '保洁员王霞'
        }, {
          id: '1564322231',
          time: '2019-12-01 19:34',
          time2: '2019-12-02 10:00',
          good: '抽油烟机',
          user: '刘女士',
          phone: '13199451349',
          area: '浙江省杭州市下城区下沙大都会风情苑8幢6单元902室',
          money: '50元',
          state: '已接单',
          user2: '保洁员王霞'
        }
      ]
    }
  },
  mounted() {},
  methods: {
    // 当前页
    handleSizeChange: function(pagesize) {
      this.pagesize = pagesize
    },
    // 换页：更新列表数据
    handleCurrentChange: function(currentPage) {
      this.currentPage = currentPage
    },
    agree(row) {
      this.dialogFormVisible = true
      this.card_id = row.id
    }
  }
}
</script>
<style lang="scss" scoped>
.laundry {
  margin-top: 55px;
}
</style>
